# coding=utf-8

__author__ = 'CLINUX'
#import subprocess
#
#cmd="c:\windows\System32\cmd.exe"
#begin=101
#end=200
#while begin<end:
#
#    p=subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,
#        stdin=subprocess.PIPE,
#        stderr=subprocess.PIPE)
#    p.stdin.write("ping 192.168.1."+str(begin)+"\n")
#    p.stdin.close()
#    p.wait()
#
#print "execution result: %s"%p.stdout.read()
#print "hello word!"
#print ("欢迎来到奥运中国!")
#print '欢迎来到奥运中国!'
#a=100.0
#b=201.1
#c=2343
#print (a+b+c)/c
#字符串访问    正向 index包含  end不包含  （和java一样）  负向相反

#word="abcdefg"
#a=word[2]
#print "a is: "+a
#b=word[1:3]
#print "b is: "+b # index 1 and 2 elements of word.
#c=word[:2]
#print "c is: "+c # index 0 and 1 elements of word.
#d=word[0:]
#print "d is: "+d # All elements of word.
#e=word[:2]+word[2:]
#print "e is: "+e # All elements of word.
#f=word[-1]
#print "f is: "+f # The last elements of word.
#g=word[-2:-1]
#print "g is: "+g # index 3 and 4 elements of word.
#h=word[-2:]
#print "h is: "+h # The last two elements.
#i=word[:-2]
#print "i is: "+i # Everything except the last two characters
#l=len(word)
#print "Length of word is: "+ str(l)

#for循环  for temp in continor
#a = ['cat', 'window', 'defenestrate']
#for  x in a:
#    print x, len(x)

#函数定义

#def sum(a,b):
#    return a+b
#
#function=sum
#
#print sum(11,11)
#print function(11,123456.000011244)

#Return a list containing an arithmetic progression of integers.
#range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.
#When step is given, it specifies the increment (or decrement).
#For example, range(4) returns [0, 1, 2, 3].  The end point is omitted!
#These are exactly the valid indices for a list of 4 elements.
#a =range(5)
#for x in a:
# print x
#
#a = range(-7,-2)
#print a
# IO文件操作
#str="C:\Users\CLINUX\Desktop\1.txt"
#f=open('1.txt','wb') # Opens file for writing.Creates this filedoesn't exist.
#
#f.write("12312312.\n")
#f.writelines("werewr2.")
#
#f.close()
#
#f=open('1.txt','r') # Opens file for reading
#
#
#for temp in f:
#    print temp
#
#f.close()
#
#
##读取控制台信息、异常等
#
#s=raw_input("Input your age:")
#if s =="":
#    raise Exception("Input must no be empty.")
#
#try:
#    i=int(s)
#except ValueError:
#    print "Could not convert data to an integer."
#except:
#    print "Unknown exception!"
#else: # It is useful for code that must be executed if the try clause does not raise an exception
#    print "You are %d"%i," years old"
#finally: # Clean up action
#    print "Goodbye!"
#继承和类
#class Base:
#    data=[]
#    str=""
##    def __init__(self):
##        self.data = []
#    def add(self, x):
#        self.data.append(x)
#        self.str+x
#    def addtwice(self, x):
#        self.add(x)
#        self.str+x
## Child extends Base
#class Child(Base):
#
#    def plus(self,a,b):
#        return a+b
##声明一个对象引用
#oChild =Child()
##oChild.__init__()
#oChild.add("str1")
#oChild.addtwice("123")
#print oChild.data
#print oChild.str
#print oChild.plus(2,3)
#jython
#import Launcher.pythonDeamo
#number = 23
#guess = int(raw_input('Enter an integer :“” '))
#if guess == number:
#    print 'Congratulations, you guessed it.' # New block starts here
#    print "(but you do not win any prizes!)" # New block ends here
#elif guess < number:
#    print 'No, it is a little higher than that' # Another block
## You can do whatever you want in a block ...
#else:
#            print 'No, it is a  higher than that' # Another block
#            print("asdas")

#for temp in range(1,8):
##        print temp
#    if temp<5:
#        print temp
#    elif temp>=5:
#        print 'this is large 5'
#        print temp+9
#running=True
#while running:
#    s = raw_input('Enter something : ')
#    if s == 'quit': break
#print "it is ok quit"

#running=False

#def printMax(a, b):
#    if a > b:
#        print a, 'is maximum'
#    else:
#        print b, 'is maximum'
#printMax(3, 4) # directly give literal values
#
#def sum(a,b):
#    if a>b:
#        print a-b
#    else:
#        print b-a
#sum(1,9)

#def sum():
#    global a
#    a=35
#    print a
#
#a=10
#print a
#sum()

#def say(message, times = 1):
#    print message * times
##say('Hello')
#say('World', 5)
#    当前目录也是sys.path的一部分
#import sys

#print 'The command line arguments are:'
#for i in sys.argv:
#    print i
#print 'The PYTHONPATH is', sys.path[0], '\n'

#import __init__
#__init__.say()
#print __init__.ver
#import sys
#dir(sys)

#for temp in range(1,2):
#    for temp1 in range(1,8):
#        print temp;print temp1

#shoplist = ['apple', 'mango', 'carrot', 'banana']
#for temp in shoplist:
#    print(temp)
#del shoplist[0]
#print "this is del later "+shoplist[0]+" is the frist"
#for temp in shoplist:
#    print temp
#shoplist = [3,5,1,4,2]
##shoplist.sort()
## index(),返回首次出现的位置
#print shoplist.index(1)
#for temp in shoplist:
#    print(temp)

#元组 和list一样的 ，只是元组不可以修改
#shoplist = (3,5,1,4,2)
#print len(shoplist)


#字典(key/value键值对)
#ab = { 'Swaroop' : 'swaroopch@byteofpython.info',
#       'Larry' : 'larry@wall.org',
#       'Matsumoto' : 'matz@ruby-lang.org',
#       'Spammer' : 'spammer@hotmail.com',
#       'Guido':'1234567'
#}
#ab.items()返回元组
#print(ab.items())
#for temp in ab.items():
#    print(temp)
#print "Swaroop's address is %s" % ab['Swaroop']
# Adding a key/value pair
#print "Guido's address is %s" % ab['Guido']
#ab['Guido'] = 'guido@python.org'
#print "Guido's address is %s" % ab['Guido']
## Deleting a key/value pair
#del ab['Spammer']
#print '\nThere are %d contacts in the address-book\n' % len(ab)
#for name, address in ab.items():
#    print 'Contact %s at %s' % (name, address)
#if 'Guido' in ab: # OR ab.has_key('Guido')
#    print "\nGuido's address is %s" % ab['Guido']

#print 5000-4965
#，shoplist[-1]表示
#序列的最后一个元素而shoplist[-2]抓取序列的倒数第二个项目。

#shoplist = ['apple', 'mango', 'carrot', 'banana']
#print shoplist[1:]





















